//
//  FirstInViewController.m
//  SMS_SDKDemo
//
//  Created by UNOHACHA王家乐 on 15/11/14.
//  Copyright © 2015年 严军. All rights reserved.
//

#import "FirstInViewController.h"

#import "AppDelegate.h"
#import "HomeViewController.h"
#import "PropertyViewController.h"
#import "ClientViewController.h"
#import "WealthViewController.h"
#import "MineViewController.h"
@interface FirstInViewController ()<UIApplicationDelegate,UIScrollViewDelegate>{
    CGRect rect;
    
}

@property(nonatomic, strong)UIScrollView *scrollView;
@property(nonatomic, strong)UITabBarController *tab;

@end

@implementation FirstInViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    rect = [UIScreen mainScreen].bounds;
    // Do any additional setup after loading the view.
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)];
    self.scrollView.contentSize = CGSizeMake(rect.size.width*3, rect.size.height);
    self.scrollView.scrollEnabled = YES;
    self.scrollView.pagingEnabled = YES;
    //self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.contentOffset = CGPointMake(rect.size.width, 0);
    self.scrollView.delegate = self;
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)];
        UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)];
        imageV.image = [UIImage imageNamed:@"shouye7.jpg"];
        [view addSubview:imageV];
        
        [self.scrollView addSubview:view];
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(rect.size.width, 0, rect.size.width, rect.size.height)];
    UIImageView *imageV1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)];
    imageV1.image = [UIImage imageNamed:@"shouye7.jpg"];
    [view1 addSubview:imageV1];
    
    [self.scrollView addSubview:view1];
    
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(rect.size.width* 2, 0, rect.size.width, rect.size.height)];
    UIImageView *imageV2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)];
    imageV2.image = [UIImage imageNamed:@"shouye7.jpg"];
    [view2 addSubview:imageV2];
    
    [self.scrollView addSubview:view2];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake((rect.size.width - 200)/2, 300, 200, 40);
    button.backgroundColor = [UIColor cyanColor];
    [button setTitle:@"立即开启" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(pressButton) forControlEvents:UIControlEventTouchUpInside];
    button.tintColor = [UIColor whiteColor];
    [view2 addSubview:button];
    
    [self.view addSubview:self.scrollView];
    
    
    
}
- (void)pressButton{
    UIApplication *app = [UIApplication sharedApplication];
    AppDelegate *app2 = app.delegate;
   
    
       
    HomeViewController *home = [[HomeViewController alloc] init];
    
    //    [General initialization:home isPoint:YES];
    
    UINavigationController *homeNavi = [[UINavigationController alloc] initWithRootViewController:home];
    home.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"首页白.png"] selectedImage:[UIImage imageNamed:@"首页蓝.png"]];
    
    PropertyViewController *property = [[PropertyViewController alloc] init];
    UINavigationController *propertyNavi = [[UINavigationController alloc] initWithRootViewController:property];
    property.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"楼盘" image:[UIImage imageNamed:@"楼盘白.png"] selectedImage:[UIImage imageNamed:@"楼盘蓝.png"]];
    
    ClientViewController *client = [[ClientViewController alloc] init];
    UINavigationController *clientNavi = [[UINavigationController alloc] initWithRootViewController:client];
    client.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"客户" image:[UIImage imageNamed:@"客户白.png"] selectedImage:[UIImage imageNamed:@"客户蓝.png"]];
    
    WealthViewController *wealth = [[WealthViewController alloc] init];
    UINavigationController *wealthNavi = [[UINavigationController alloc] initWithRootViewController:wealth];
    wealth.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"财富" image:[UIImage imageNamed:@"财产白.png"] selectedImage:[UIImage imageNamed:@"财产蓝.png"]];
    
    MineViewController *mine = [[MineViewController alloc] init];
    UINavigationController *mineNavi = [[UINavigationController alloc] initWithRootViewController:mine];
    mine.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:[UIImage imageNamed:@"我的白.png"] selectedImage:[UIImage imageNamed:@"我的蓝.png"]];
    //mine.tabBarItem =
    
    self.tab = [[UITabBarController alloc] init];
    
    
    _tab.viewControllers = @[homeNavi,propertyNavi,clientNavi,wealthNavi,mineNavi];
    
    /* tabBar背景颜色 */
    _tab.tabBar.barTintColor = [UIColor blackColor];
    _tab.tabBar.tintColor = [UIColor whiteColor];
    
    app2.window.rootViewController = _tab;
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
